<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="org.springside.modules.security.springsecurity.SpringSecurityUtils"%>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="com.lab.account.domain.User"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Mini-Web 帐号管理</title>
		<%@ include file="/common/meta.jsp"%>
		<link href="${staticCtx}/style/yui.css" type="text/css" rel="stylesheet" />
		<link href="${staticCtx}/style/style.css" type="text/css" rel="stylesheet" />
		<script src="${staticCtx}/script/jquery/jquery.js" type="text/javascript"></script>
		<script src="${staticCtx}/script/jquery/table.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				 $('input.doDelete').bind('click', function(event) {
					if (confirm("确认删除?")){
						  //$('form[name=frm-delete]').submit();
						  $(this).parent().submit();
					}
					
					return false;
				});
			});
		</script>
	</head>

	<body>
		<div id="doc3">
			<%@ include file="/common/header.jsp"%>
			<div id="bd">
				<div id="yui-main">
					<div class="yui-b">
						<div id="message">
							<div id="filter">
								你好,
								<%=SpringSecurityUtils.getCurrentUserName()%>.&nbsp;&nbsp; 邮箱:
								<%=((User) SecurityContextHolder.getContext()
							.getAuthentication().getPrincipal()).getEmail()%>
							</div>
							<div id="content">
								<table id="contentTable">
									<tr>
										<th>
											登录名
										</th>
										<th>
											电邮
										</th>
										<th>
											角色
										</th>
										<th>
											操作
										</th>
									</tr>
									<c:forEach items="${userList}" var="user">
										<tr>
											<td>
												${user.username}&nbsp;
											</td>
											<td>
												${user.email}&nbsp;
											</td>
											<td>
												${user.roleNames}&nbsp;
											</td>
											<td>
												&nbsp;
												<security:authorize ifAnyGranted="ROLE_浏览用户">
													<security:authorize ifNotGranted="ROLE_修改用户">
														<a href="${ctx}/account/users/${user.id}">查看</a>&nbsp;
								</security:authorize>
												</security:authorize>

												<security:authorize ifAnyGranted="ROLE_修改用户">
													<a class="doDisplay" href="${ctx}/account/users/${user.id}">修改</a>
													<form:form name="frm-delete" action="${ctx}/account/users/${user.id}" method="delete">
														<input class="doDelete" type="submit" value="删除" />
													</form:form>
												</security:authorize>
											</td>
										</tr>
									</c:forEach>
								</table>
							</div>

							<div>
								第${page.pageNo}页, 共${page.totalPages}页
								<a href="javascript:jumpPage(1)">首页</a>
								<s:if test="page.hasPre">
									<a href="javascript:jumpPage(${page.prePage})">上一页</a>
								</s:if>
								<s:if test="page.hasNext">
									<a href="javascript:jumpPage(${page.nextPage})">下一页</a>
								</s:if>
								<a href="javascript:jumpPage(${page.totalPages})">末页</a>

								<security:authorize ifAnyGranted="ROLE_修改用户">
									<a href="${ctx}/account/users/-1">增加新用户</a>
								</security:authorize>
							</div>
						</div>
					</div>
				</div>
				<%@ include file="/common/footer.jsp"%>
			</div>
	</body>
</html>
